package org.lyq.erp.auth.resources.service;

import java.util.List;
import javax.annotation.Resource;
import org.lyq.erp.auth.resources.mapper.ResourcesMapper;
import org.lyq.erp.auth.resources.pojo.Resources;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ResourcesServiceImpl implements ResourcesService {
	
	@Resource
	private ResourcesMapper resourcesMapper;

	public List<Resources> selectALlResources() {
		return this.resourcesMapper.selectAllResources();
	}

	@Transactional
	public void insert(Resources resources) {
		resources.setCreatetime(Long.valueOf(System.currentTimeMillis()));
		resources.setUpdatetime(Long.valueOf(System.currentTimeMillis()));
		this.resourcesMapper.insertSelective(resources);
	}

	@Transactional
	public void update(Resources resources) {
		resources.setUpdatetime(Long.valueOf(System.currentTimeMillis()));
		this.resourcesMapper.updateByPrimaryKeySelective(resources);
	}

	public Resources selectByPrimaryKey(Integer resUuid) {
		return this.resourcesMapper.selectByPrimaryKey(resUuid);
	}

	@Transactional
	public void delete(Integer resUuid) {
		this.resourcesMapper.deleteResByresUuid(resUuid);

		this.resourcesMapper.deleteAllResAndRole(resUuid);
	}

	public List<Resources> selectMyAllResources(Integer empUuid) {
		return this.resourcesMapper.selectMyAllResources(empUuid);
	}
}
